package com.hospital;

import io.rong.imkit.RongIM;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.hospital.pony.base.BaseActivity;
import com.hospital.pony.model.ApplyModel;
import com.hospital.pony.model.DortorModel;
import com.hospital.pony.view.DialogMsg;

public class UpdateDoctorMessageActivity extends BaseActivity {
	// title
	private TextView mTvTitle;
	// 返回
	private ImageView mIvBack;
	// 查询按钮
	private TextView mtvtitle;

	DortorModel noticeModel;

	private TextView departmentHosName;
	private TextView doctorName;
	private TextView doctorSex;
	private TextView doctorYear;
	private TextView departmentName;
	private TextView doctorMessage;

	private Button mbtnPay;
	private TextView mtvShopPrice;

	private int choiceTime = 1;
	private DialogMsg dialogMsg;
	private ImageView mivUserImage;
	private Button mbtnIM;
	private ApplyModel applyModel;
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_doctornewsmsg);
		initWidget();
		initData();
	}

	@Override
	public void initWidget() {
		dialogMsg = new DialogMsg(this);
		dialogMsg.Set_Msg("预约成功，可在个人中心查看自己的预约信息");

		dialogMsg.submit_ok().setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				UpdateDoctorMessageActivity.this.finish();
				dialogMsg.Close();
			}
		});
		dialogMsg.submit_no().setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				UpdateDoctorMessageActivity.this.finish();
				dialogMsg.Close();
			}
		});

		mbtnPay = (Button) findViewById(R.id.mbtnPay);
		mbtnPay.setOnClickListener(this);
		mivUserImage = (ImageView) findViewById(R.id.mivUserImage);
		departmentHosName = (TextView) findViewById(R.id.departmentHosName);
		doctorName = (TextView) findViewById(R.id.doctorName);
		doctorSex = (TextView) findViewById(R.id.doctorSex);
		doctorYear = (TextView) findViewById(R.id.doctorYear);
		departmentName = (TextView) findViewById(R.id.departmentName);
		doctorMessage = (TextView) findViewById(R.id.doctorMessage);

		mtvShopPrice = (TextView) findViewById(R.id.mtvShopPrice);
		// mtvtitle = (TextView) findViewById(R.id.mtvtitle);

		mIvBack = (ImageView) findViewById(R.id.mIvBack);
		mTvTitle = (TextView) findViewById(R.id.mTvTitle);
		mTvTitle.setText("医生详情");
		mIvBack.setVisibility(View.VISIBLE);
		mIvBack.setOnClickListener(this);

		mbtnIM = (Button) findViewById(R.id.mbtnIM);
		mbtnIM.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		if(v.getId()==R.id.mIvBack){
			UpdateDoctorMessageActivity.this.finish();
		}
		if(v.getId()==R.id.mbtnIM){
			RongIM.getInstance().startPrivateChat(this, noticeModel.getUid(), noticeModel.getUname());

		}
		if(v.getId()==R.id.mbtnPay){
			Intent mbtnPay = new Intent(this, UpdatePayActivity.class);
			mbtnPay.putExtra("msg", noticeModel);
			mbtnPay.putExtra("applyModel",applyModel);
			startActivity(mbtnPay);
		}
	}



	@Override
	public void initData() {
		applyModel = (ApplyModel) this.getIntent().getSerializableExtra("applyModel");

		noticeModel = (DortorModel) this.getIntent().getSerializableExtra("msg");
		departmentHosName = (TextView) findViewById(R.id.departmentHosName);
		doctorName = (TextView) findViewById(R.id.doctorName);
		doctorSex = (TextView) findViewById(R.id.doctorSex);
		doctorYear = (TextView) findViewById(R.id.doctorYear);
		departmentName = (TextView) findViewById(R.id.departmentName);
		doctorMessage = (TextView) findViewById(R.id.doctorMessage);

		departmentHosName.setText(noticeModel.getDepartmentHosName());
		// 书名，出版社，种类
		doctorName.setText("名字：" + noticeModel.getDoctorName());
		doctorSex.setText("性别：" + noticeModel.getDoctorSex());

		doctorYear.setText("年限：" + noticeModel.getDoctorYear());
		departmentName.setText("科室：" + noticeModel.getDepartmentName());

		doctorMessage.setText("        " + noticeModel.getDoctorMessage());

		if (noticeModel.getDoctorSex().equals("男")) {
			mivUserImage.setImageResource(R.drawable.icon_nan);
		} else {
			mivUserImage.setImageResource(R.drawable.icon_nv);
		}

		// if (!TextUtils.isEmpty(noticeModel.getDoctorImage())) {
		// Picasso.with(this).load(Consts.URL_IMAGE_LOCAL +
		// noticeModel.getDoctorImage()).placeholder(R.drawable.default_drawable_show_pictrue)
		// .into(mivUserImage);
		// }
		mtvShopPrice.setText("问诊费：" + noticeModel.getDoctorNumber() + "元");
		// mtvShopPrice.setText("预约数："+noticeModel.getTotalNumber()+"/"+noticeModel.getDoctorNumber());
	}

	

}
